package payroll;

import static org.junit.jupiter.api.Assertions.assertEquals;

import org.junit.jupiter.api.Test;

public class AddEmployeeTest {
    
    //添加钟点工：AddEmp empId name address H  hourly-rate
    @Test
    void testAddHourlyEmployee(){
        int empId = 1001;
        String name = "Bill";
        String address = "No 391 ,Huanghe Road.";
        double hourlyRate = 8.0;

        Transaction t = new AddHourlyEmployeeTransaction(empId,name,address,hourlyRate);
        t.execute();
        Employee e = PayrollDatabase.getEmployee(empId);
        assertNotNull(e);
        assertEquals(empId, e.getEmpId());
        assertEquals(name, e.getName());
        assertEquals(address, e.getAddress());

        PaymentClassification pc = e.getPaymentClassification();
        assertTrue(pc instanceof HourlyClassification);
        HourlyClassification hc = (HourlyClassification) pc;
        assertEquals(hourlyRate, hc.getHourlyRate(),0.01);

        PaymentMethod pm = e.getPaymentMethod();
        assertTrue(pm instanceof HoldMethod);
    }

    private void assertTrue(boolean b) {
    }

    private void assertNotNull(Employee e) {
    }
}
